clear 
close all


%% Import data

import_file_name_1 = 'mat_files\m2023_01_07_1_effective_U_phase_0p5_delta_N_vs_modfreq3_evol_36p25ms.mat';
import_file_name_2 = 'mat_files\m2023_01_06_1_effective_U_phase_m0p5_delta_N_vs_modfreq3_evol_36p25ms.mat';
import_file_name_3 = 'mat_files\m2023_01_30_1_effective_U_modfreq3_1070_CK_DC_delta_N_vs_modfreq3_evol_36p25ms';

data_phase_0p5 = load(import_file_name_1);
data_phase_m0p5 = load(import_file_name_2);
data_modfreq3_1070 = load(import_file_name_3);

uniquefvals = cat(1, data_phase_0p5.uniquefvals, 1070);

diff_atom_num_phase_0p5 = cat(1, data_phase_0p5.diff_atom_num_new, data_modfreq3_1070.diff_atom_num_new(2));
err_diff_atom_num_0p5 = cat(1, data_phase_0p5.err_diff_atom_num_new, data_modfreq3_1070.err_diff_atom_num_new(2));

diff_atom_num_phase_m0p5 = cat(1, data_phase_m0p5.diff_atom_num_new, data_modfreq3_1070.diff_atom_num_new(1));
err_diff_atom_num_m0p5 = cat(1, data_phase_m0p5.err_diff_atom_num_new, data_modfreq3_1070.err_diff_atom_num_new(1));

evolution_dur = '36.25';
J_eff = 10.6; % from single particle quantum walk on 2023/01/04
U_data = (1010 - uniquefvals)/J_eff;


%% Plot

figure
tiledlayout(1, 1, 'TileSpacing', 'None', 'padding','tight')

nexttile
hold on 
err1 = errorbar(U_data, diff_atom_num_phase_0p5, err_diff_atom_num_0p5, ...
    'o', 'DisplayName', '\theta = 0.5\pi');
err2 = errorbar(U_data, diff_atom_num_phase_m0p5, err_diff_atom_num_m0p5, ...
    'o',  'DisplayName', '\theta = -0.5\pi');
err1.CapSize = 0;
err2.CapSize = 0;
hold off

xlabel('U (J)')
ylabel('\Delta n')
ylim([-0.8 0.8])
xticks([linspace(-6,6,7)])
yticks([-0.5,0,0.5])
legend

